In [1]:
from __future__ import division
import os
import numpy as np
import pandas as pd
#import lmfit
In [7]:
%matplotlib inline
import matplotlib.pyplot as plt
In [17]:
d = {}
for bsearch_ph_sel in ['all-ph', 'Dex', 'AND-gate']:
data_file = 'results/usALEX-5samples-PR-raw-%s.txt' % bsearch_ph_sel
d[bsearch_ph_sel] = pd.read_csv(data_file, sep="\s+").set_index('sample')[['E_pr_fret_kde']]
#d[bsearch_ph_sel].columns = [bsearch_ph_sel]
In [12]:
fig, ax = plt.subplots()
for bs, data in d.items():
data.plot(label=bs, ax=ax)
In [21]:
(d['AND-gate'] - d['all-ph']).abs().max()*100
Out[21]:
In [25]:
(d['AND-gate'] - d['Dex']).abs()
Out[25]:
In [23]:
(d['all-ph'] - d['Dex']).abs().max()*100
Out[23]:
In [26]:
d['Dex']
Out[26]:
In [2]:
#bsearch_ph_sel = 'all=ph'
#bsearch_ph_sel = 'AND-gate'
bsearch_ph_sel = 'Dex'
data_file = 'results/usALEX-5samples-PR-raw-%s.txt' % bsearch_ph_sel
These are the RAW proximity ratios for the 5 samples (only background correction, no leakage nor direct excitation):
In [3]:
data_raw = pd.read_csv(data_file, sep="\s+").set_index('sample')
data_raw[['E_pr_fret', 'E_pr_fret_kde']]
Out[3]:
In [4]:
leakage_coeff_fname = 'results/usALEX - leakage coefficient DexDem.txt'
leakage = np.loadtxt(leakage_coeff_fname)
print 'Leakage coefficient:', leakage
In [5]:
dir_ex_t_datasheet_fname = 'results/Dyes - ATT0647N-ATTO550 abs X-section ratio at 532nm.txt'
dir_ex_t_datasheet = np.loadtxt(dir_ex_t_datasheet_fname)
print 'Direct excitation (dir_ex_t) from datasheet:', dir_ex_t_datasheet
In [6]:
gamma_coeff_fname = 'results/usALEX - gamma factor - all-ph.txt'
gamma = np.loadtxt(gamma_coeff_fname)
print 'Gamma factor:', gamma
And these are the FRET efficiencies fitted from corrected histograms for the same 5 samples:
In [7]:
data_file = 'results/usALEX-5samples-E-corrected-all-ph.txt'
data_corr = pd.read_csv(data_file, sep="\s+").set_index('sample')
data_corr[['E_pr_fret', 'E_pr_fret_kde']]
Out[7]:
The expression to convert RAW PR values to corrected FRET efficiencies:
$$ E = \frac{E_{R} \left(L_{k} + d_{exT} \gamma + 1\right) - L_{k} - d_{exT} \gamma}{E_{R} \left(L_{k} - \gamma + 1\right) - L_{k} + \gamma}$$See Derivation of FRET and S correction formulas for the derivation.
We load FRETBursts software that provides this function (as fretmath.correct_E_gamma_leak_dir
):
In [8]:
%run load_fretbursts.py --nogui
Using datasheet values for $d_{exT}$ we the following FRET efficiencies:
In [9]:
E_datasheet = fretmath.correct_E_gamma_leak_dir(data_raw.E_pr_fret_kde,
leakage=leakage,
dir_ex_t=dir_ex_t_datasheet,
gamma=gamma)*100
E_datasheet
Out[9]:
In [10]:
out = data_corr[['E_pr_fret_kde']].copy()*100
out.columns = ['E_alex']
out['E_datasheet'] = E_datasheet
out
Out[10]:
In [11]:
out.plot(alpha=0.4, lw=3, style=dict(E_alex='-ob', E_datasheet='-sr'));
NOTE: The corrected FRET efficiencies using the datasheet and μs-ALEX-based direct excitation do not match well.
In [12]:
import lmfit
In [13]:
def residuals_absolute(params, E_raw, E_ref):
dir_ex_t = params['dir_ex_t'].value
return E_ref - fretmath.correct_E_gamma_leak_dir(E_raw,
leakage=leakage,
gamma=gamma,
dir_ex_t=dir_ex_t)
In [14]:
def residuals_relative(params, E_raw, E_ref):
dir_ex_t = params['dir_ex_t'].value
return (E_ref - fretmath.correct_E_gamma_leak_dir(E_raw,
leakage=leakage,
gamma=gamma,
dir_ex_t=dir_ex_t))/E_ref
In [15]:
params = lmfit.Parameters()
params.add('dir_ex_t', value=0.05)
In [16]:
m = lmfit.minimize(residuals_absolute, params, args=(data_raw.E_pr_fret_kde, data_corr.E_pr_fret_kde))
lmfit.report_fit(m.params, show_correl=False)
In [17]:
m = lmfit.minimize(residuals_relative, params, args=(data_raw.E_pr_fret_kde, data_corr.E_pr_fret_kde))
lmfit.report_fit(m.params, show_correl=False)
NOTE: The fitted
dir_ex_t
is XX% as opposed to 10.6% as expected from the absorption spectra of ATTO550 and ATTO647 at 532nm.
In [21]:
m.params['dir_ex_t'].value
Out[21]:
In [20]:
with open('results/usALEX - leakage coefficient dir_ex_t.txt', 'w') as f:
f.write(str(m.params['dir_ex_t'].value))
In [20]: